# -*- coding: utf-8 -*-
import struct

bmp = open('test.bmp', 'rb')
bmp_bin = bmp.read()
bmp.close()

print len(bmp_bin)

offsize = struct.unpack_from('<HL2HL', bmp_bin, 0)[-1]
print hex(offsize)

data = bmp_bin[offsize:]

print len(data)
print 272*480*3

out = '''#include "lcd.h"

u32 bitmap[LCD_HEIGHT][LCD_WIDTH] =
{'''

for h in range(271, -1, -1):
    out += '\n    '
    for w in range(0, 480 * 3, 3):
        i = h * 480 * 3 + w
        rgb = ((ord(data[i + 2]) << 16) | (ord(data[i + 1]) << 8) | (ord(data[i + 0]) << 0))
        out += "%#x, " % rgb

out += '''
};
'''
res = open('../src/bitmap.c', 'w')
res.write(out)
res.close()
